#!/usr/bin/env python
"""
Standard options
"""
import argparse


def get_common_parser ():
    """
    Common options:

            --verbose
            --version
            --log_file
            --skip_parameter_logging
            --debug
    """
    common_parser = argparse.ArgumentParser(description='Common options',
                                            add_help=False)
    common_parser.add_argument('--verbose', "-v", const=1, default=0, nargs='?', type= int,
                                help="Print more verbose messages for each additional verbose level.")
    common_parser.add_argument('--version', action='version', version='%(prog)s 1.0')
    common_parser.add_argument("-L", "--log_file", metavar="FILE", type=str,
                                  help="Name and path of log file")
    common_parser.add_argument("--skip_parameter_logging", action="store_true",
                                help="Do not print program parameters to log.")
    common_parser.add_argument("--debug", const=1, default=0, nargs='?', type= int,
                                help="Set default program parameters in debugging mode.")

    return common_parser


def get_common_pipeline_parser ():
    """
    Common options:

            --verbose
            --version
            --log_file
            --skip_parameter_logging
            --debug
    """
    common_parser = argparse.ArgumentParser(description='Common options',
                                            add_help=False)
    common_parser.add_argument('--verbose', "-v", const=1, default=0, nargs='?', type= int,
                                help="Print more verbose messages for each additional verbose level.")
    common_parser.add_argument('--version', action='version', version='%(prog)s 1.0')
    common_parser.add_argument("-L", "--log_file", metavar="FILE", type=str,
                                  help="Name and path of log file")
    common_parser.add_argument("--skip_parameter_logging", action="store_true",
                                help="Do not print program parameters to log.")
    common_parser.add_argument("--debug", const=1, default=0, nargs='?', type= int,
                                help="Set default program parameters in debugging mode.")




    #
    #   pipeline
    #
    pipline_options = common_parser.add_argument_group('pipeline arguments')
    pipline_options.add_argument("-T", "--target_tasks", action="append",
                                metavar="JOBNAME", type=str,
                                help="Target task(s) of pipeline.", default = [])
    pipline_options.add_argument("-j", "--jobs", default=1, metavar="N", type=int,
                                help="Allow N jobs (commands) to run simultaneously.")
    pipline_options.add_argument("-n", "--just_print", action="store_true",
                                help="Don't actually run any commands; just print the pipeline.")
    pipline_options.add_argument("--flowchart", metavar="FILE", type=str,
                                help="Don't run any commands; just print pipeline as a flowchart.")

    #
    #   Less common pipeline options
    #
    pipline_options.add_argument("--key_legend_in_graph",     action="store_true",
                                help="Print out legend and key for dependency graph.")
    pipline_options.add_argument("--draw_graph_horizontally", action="store_true",
                                help="Draw horizontal dependency graph.")
    pipline_options.add_argument("--flowchart_format", metavar="FORMAT",
                                type=str, choices = ["svg", "svgz", "png", "jpg", "pdf", "dot"],
                                #  "eps", "jpeg", "gif", "plain", "ps", "wbmp", "canon",
                                #  "cmap", "cmapx", "cmapx_np", "fig", "gd", "gd2",
                                # "gv", "imap", "imap_np", "ismap", "jpe", "plain-ext",
                                # "ps2", "tk", "vml", "vmlz", "vrml", "x11", "xdot", "xlib"
                                default = 'svg',
                                help="format of dependency graph file. Can be 'pdf', " +
                                      "'svg', 'svgz' (Structured Vector Graphics), 'pdf', " +
                                      "'png' 'jpg' (bitmap  graphics) etc ")
    pipline_options.add_argument("--forced_tasks", action="append",
                                metavar="JOBNAME", type=str,
                                help="Task(s) which will be included even if they are up to date.", default = [])



    return common_parser


